import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { Product } from '@/api'
export const useCategoryStore = defineStore('category', () => {
    // 加载树形分类
    let load_select_cates = ref([])
    let load_select_cate = async () => {
        let { status, data } = await Product.category_tree(1)
        if (status) {
            load_select_cates.value = data
        }
    }
    // 加载普通分类
    let category_list = ref([])
    let load_category = async () => {
        let { status, data } = await Product.get_product_category(0)
        if (status) {
            category_list.value = data.list
        }
    }
    return {
        load_select_cates,
        load_select_cate,
        load_category,
        category_list
    }
},
    // 持久化插件
    { persist: { storage: sessionStorage } }
)




